from flask import jsonify
from typing import Any, Optional, Union, Dict, List

class ResponseUtil:
    @staticmethod
    def success(data: Any = None, message: str = "成功") -> tuple:
        response = {
            "success": True,
            "errcode": 0,
            "message": message,
            "data": data if data is not None else []
        }
        return jsonify(response), 200

    @staticmethod
    def error(message: str, errcode: int = 2, status_code: int = 500) -> tuple:
        response = {
            "success": False,
            "errcode": errcode,
            "message": message,
            "data": []
        }
        return jsonify(response), status_code

    @staticmethod
    def missing_params(message: str = "缺少必要参数") -> tuple:
        return ResponseUtil.error(message, errcode=3, status_code=400) 